package com.fenghongzhang.day008;

public class User {
    String name;
    int age;
    String email;
    String address;


    //想要有名字和邮箱的构造器
    public User(String name, String email){
        this.name = name;
        this.email = email;
    }
    private User() {
    }

//    //想要有名字和地址的构造器
//    public User(String name, String address){
//        this.name = name;
//        this.address = address;
//    }

    public static class Builder {
        private String name;
        private int age;
        private String email;
        private String address;

        public Builder setName(String name) {
            this.name = name;
            return this;
        }

        public void setAge(int age) {
            this.age = age;
        }

        public Builder setEmail(String email) {
            this.email = email;
            return this;
        }

        public Builder setAddress(String address) {
            this.address = address;
            return this;
        }

        public User build() {
            User user = new User();
            user.name = name;
            user.age = age;
            user.email = email;
            user.address = address;
            return user;
        }
    }
    public static void main(String[] args) {

        User user = new Builder().setName("哈哈").setAddress("地址").setEmail("嗯啊").build();


    }
}


